package io.github.biezhi.elves.bidding.model;

import lombok.Data;
import io.github.biezhi.elves.common.MapConstants;
import io.github.biezhi.elves.utils.AbstractObject;
import io.github.biezhi.elves.utils.StringUtils;

/**
 * 记录公告标题数据DTO对象
 *
 */
@Data
public class RecordBiddingNoticeDTO extends AbstractObject {
	//id
	private Long id;
	//取的是网站上的标题链接的后缀作为标题id
	private String recordId;
	//公告类型
	private String noticeType;
	//采购方式
	private String purchaseMode;
	//记录用哪个关键字搜索
	private String keyword;
	//标题
	private String title;
	//公告详情链接
	private String noticeDetailUrl;
	//分页页码
	private Integer size;
	//操作方式(1：下载公告详情html内容；2：解析公告详情html内容，并提取所需字段信息)
	private Integer operationMode = 0;
	//发布日期
	private String pubdate;
	//网站名称
	private String siteName;
	
	public String getSiteName() {
		return getSiteNameToEnByUrl(this.noticeDetailUrl);
	}
	
	/**
	 * 根据url获取网站名称
	 * @param url
	 * @return
	 */
	private String getSiteNameToEnByUrl(String url) {
		String resultSiteName = "";
		if (!StringUtils.isNullOrEmpty(url)) {
			String result = url.replace("http://", "").replace("https://", "");
			result = result.substring(0, result.indexOf("/"));
			resultSiteName = StringUtils.getValueForKey(result, MapConstants.SITE_BY_EN_MAP);
		}
		return resultSiteName;
	}
}